# Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2015 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************

lsm = read('land_sea_mask.grib')
lsm = (lsm >= 0.5)
#plot(lsm)

t2m = read('t2m.grib')
all_mean = integrate(t2m)
print("means of original fields: ", all_mean)


land_mean = integrate(t2m, lsm) # compute the mean values from each field
if land_mean = nil then
    print('No valid data points')
else
    print("means of just land points: ", land_mean)
end if
